<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);

namespace app\api\model\user;

use app\api\service\User as UserService;
use app\common\model\user\PointsLogView as PointsLogModel;
use think\facade\Db;
/**
 * 用户余额变动明细模型
 * Class PointsLog
 * @package app\api\model\user
 */
class PointsLog extends PointsLogModel
{
    /**
     * 获取日志明细列表
     * @return \think\Paginator
     * @throws \cores\exception\BaseException
     * @throws \think\db\exception\DbException
     */
    public function getList($param)
    {
        // 当前用户ID
        $userId = UserService::getCurrentLoginUserId();
        return $this->where('user_id', '=', $userId)
            ->order(['create_time' => 'desc'])
            ->paginate(15);
    }



     /**
     * 获取日志明细列表
     * @return \think\Paginator
     * @throws \cores\exception\BaseException
     * @throws \think\db\exception\DbException
     */
    // public function getListNew($param)
    // {
       // $userInfo = UserService::getCurrentLoginUser(true);

        // $sql = " SELECT * from ( (SELECT u.mobile ,l.`value` AS `value`,l.`describe` AS `describe`,l.create_time as create_time FROM yoshop_user u LEFT JOIN yoshop_user_points_log l on u.user_id=l.user_id  where u.mobile='".$userInfo['mobile']."' )  UNION (SELECT user_phone AS mobile,integral_type AS `value`,remake as `describe`,UNIX_TIMESTAMP(create_time) AS create_time FROM java_task_record where user_phone='".$userInfo['mobile']."') ) newPoints";
        
        // // 获取列表数据
        // if(isset($param['type']) && $param['type'] = 1){
        //     $sql .= " where value not like '%-%'"; 

        // }else if(isset($param['type']) && $param['type'] = 2){ //支出记录
        //     $sql .= " where value like '%-%'"; 
        // }
        // $sql .= " ORDER BY create_time desc";

        // $list =Db::query($sql);
        // return $list;
    // }

     

}